java-print 相关问题


print() 使线程本地缓存无效?

在 Java/Kotlin 或任何 JVM 语言中,每个线程都有一个“本地内存”AKA。 “缓存”。当一个线程想要将一个变量写入内存时,它首先更新自己的值......


Java Swing 更改为 JButton 背景颜色不显示

以下程序代码是我的应用程序的精简版本。更改为 尽管 print 命令显示,但第 45、47,48 行中的背景颜色未显示 他们已经生效了...


使用python的mechanize自动网站登录

我正在尝试自动登录一个网站,该网站的登录表单具有以下 HTML 代码(摘录): 我正在尝试自动登录一个网站,其登录表单具有以下 HTML 代码(摘录): <tr> <td width="60%"> <input type="text" name="username" class="required black_text" maxlength="50" value="" /> </td> <td> <input type="password" name="password" id="password" class="required black_text" maxlength="50" value="" /> </td> <td colspan="2" align="center"> <input type="image" src="gifs/login.jpg" name="Login2" value="Login" alt="Login" title="Login"/> </td> </tr> 我正在使用python的mechanize模块进行网页浏览。以下是代码: br.select_form(predicate=self.__form_with_fields("username", "password")) br['username'] = self.config['COMMON.USER'] br['password'] = self.config['COMMON.PASSWORD'] try: request = br.click(name='Login2', type='image') response = mechanize.urlopen(request) print response.read() except IOError, err: logger = logging.getLogger(__name__) logger.error(str(err)) logger.debug(response.info()) print str(err) sys.exit(1) def __form_with_fields(self, *fields): """ Generator of form predicate functions. """ def __pred(form): for field_name in fields: try: form.find_control(field_name) except ControlNotFoundError, err: logger = logging.getLogger(__name__) logger.error(str(err)) return False return True return __pred 不知道我做错了什么...... 谢谢 该网站有可能在登录期间使用java脚本进行回发。我记得很清楚,对于 ASP .Net 站点,您需要获取隐藏表单字段,例如 VIEWSTATE 和 EVENTTARGET 并将它们发布到新 Page 。 您为什么不发送问题网站的链接?之后就变得相对容易弄清楚了 尝试使用 Selenium 和 PhantomJS from selenium import PhantomJS import platform if platform.system() == 'Windows': # .exe for Windows PhantomJS_path = './phantomjs.exe' else: PhantomJS_path = './phantomjs' service_args = [ # Proxy (optional) '--proxy=<>', '--proxy-type=http', '--ignore-ssl-errors=true', '--web-security=false' ] browser = PhantomJS(PhantomJS_path, service_args=service_args) browser.set_window_size(1280, 720) # Window size for screenshot (optional) login_url = "<url_here>" # Credentials Username = "<insert>" Password = "<insert>" # Login browser.get(login_url) browser.save_screenshot('login.png') print browser.current_url browser.find_element_by_id("<username field id>").send_keys(Username) browser.find_element_by_id("<password field id>").send_keys(Password) browser.find_element_by_id("<login button id>").click() print (browser.current_url) browser.get(scrape_url) print browser.page_source browser.quit() ''' python 和 pycharm 设置路径变量 点维辛检查 包管理器 python 如何安装新版本 python最新版本 - python 3.7.2 用户环境变量 蟒蛇 pyton 中的命令行 '''


UnboundLocalError:无法访问未与值关联的局部变量“print”?

这是代码 def takeCommand() : r = 语音识别.Recognizer() 以 voice_recognition.Microphone() 作为源: print("正在听……") r.pause_threshol...


有没有办法将课堂上的文本转换为可打印的?

当我运行代码时,一切正常,但 str 不适用于类。当我点击运行时,它给我经销商有(, 当我运行代码时,一切正常,但 str 不适用于类。当我单击运行时,它给我经销商有(<main.Card对象位于0x0000020D00046720>,<main.Card对象位于0x0000020D00045850>) 您有 [<main.Card 对象位于 0x0000020D00045A90>、<main.Card 对象位于 0x0000020D00046840>],总共 13 个 选择:1 == 留下,2 == 击中 你能帮我吗?我真的需要你的帮助 import random playerIn = True dealerIn = True class Card: def __init__(self, face): self.face = face def __str__(self): return str(self.face) all_cards = [] for face in [2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace', 'Jack', 'Queen', 'King', 'Ace']: all_cards.append(Card(face)) playerhand = [] dealerhand = [] def dealcard(turn): card = random.choice(all_cards) turn.append(card) all_cards.remove(card) def total(turn): total = 0 Ace_11 = 0 for card in turn: if card in range(11): total += card elif card in ['King', 'Jack', 'Queen']: total += 10 else: total += 11 Ace_11 += 1 while Ace_11 and total > 21: total -= 10 Ace_11 -= 1 return total def revealdealerhand(): if len(dealerhand) == 2: return dealerhand[0] elif len(dealerhand) > 2: return dealerhand[0], dealerhand[1] for c in range(2): dealcard(dealerhand) dealcard(playerhand) while playerIn or dealerIn: print('Dealer had', revealdealerhand()) print('You have', playerhand, 'for a total of', total(playerhand)) if playerIn: stayORhit = input('Choose: 1 == Stay, 2 == Hit ') if total(dealerhand) > 16: dealerIn = False else: dealcard(dealerhand) if stayORhit == '1': playerIn = False else: dealcard(playerhand) if total(playerhand) >= 21: break elif total(dealerhand) >= 21: break if total(playerhand) == 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print("BlackJack! You win! Congarts.") elif total(dealerhand) == 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('BlackJack! Dealer wins!') elif total(playerhand) > 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('You bust! dealer wins!') elif total(dealerhand) > 21: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('Dealer busts! You win!') elif 21 - total(dealerhand) > 21 - total(playerhand): print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print("Dealer busts! You win!") elif 21 - total(dealerhand) < 21 - total(playerhand): print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('You bust! Dealer won!') else: print('You have', playerhand, 'for a total of', total(playerhand), dealerhand, 'for a total of', total(dealerhand)) print('It is a tie!') 您可以覆盖 __repr__ 而不是 __str__: class Card: def __init__(self, face): self.face = face def __repr__(self): return str(self.face)


数形成三角形的三元组

问题很简单;给定 n (3 <= n <= 10^5), count all triplets i, j, k (0 < i < j < k <= n) so that they can be side lengths of a non-degenerate triangle. Print the answer m...


仅从文件中读取 1 个值

Python 文件: 名称=[] 以 open("names.csv") 作为文件: 对于文件中的行: 名称、颜色 = line.rstrip().split(",") print(f"{名称}, {颜色}") CSV ...


print/repr 中显示的十六进制整数代表什么?

在如下所示的交互式会话中: >>> f=open('test.txt','w') >>> f 0x6e610 代表什么以及我能做什么


Python向http请求返回图像

我在 iis 中使用 *.py 的处理程序“c:...\python.exe %s %s”设置 python。然后想要提供像“https://.../getpng.py?no=1”这样的url来将图像流返回到html,如下所示 我在 iis 中使用 *.py 的处理程序“c:...\python.exe %s %s”设置 python。然后想要提供像“https://.../getpng.py?no=1”这样的url来将图像流返回到html,如下所示 <img src="https://.../getpng.py?no=1"> getpng.py 很简单,如下所示。 with open('C:\\inetpub\\wwwroot\\test\\test1.png', 'rb') as f: filecontent = f.read() print('Content-Type: image/png\r\n\r\n') print(filecontent ) 图片路径正确。文件内容正确。但html页面总是显示损坏的图像。 看起来“打印(文件内容)”失败了。有解决这个问题的提示吗? 我尝试了 sys.stdout.write 但这也不起作用。 还尝试了以下方法均无效 print('内容类型:图像/png ' + 文件内容 ) print('内容类型:图像/png {0}'.format(文件内容)) 您可以使用base64在网页上显示图像; import base64 with open('QR.jpg', 'rb') as image_file: base64_bytes = base64.b64encode(image_file.read()) #print(base64_bytes) base64_string = base64_bytes.decode() print(base64_string) # For insert into the img tag. 比进入html: <img src=" data:image/jpeg; data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ.... " alt="QR.jpg" />


VSCode 仅从 csv 文件读取 1 个值[已关闭]

Python 文件: 名称=[] 以 open("names.csv") 作为文件: 对于文件中的行: 名称、颜色 = line.rstrip().split(",") print(f"{名称}, {颜色}") CSV ...


读取和过滤 CSV 文件列

我正在读取数据帧并使用如下条件查找len: 将 pandas 导入为 pd gf = pd.read_csv(raw_github_csv_file_url) print(len(gf[gf["性别"]=="男"])) 我的 CSV...


如何决定torchsummary.summary(model=model.policy, input_size=(int, int, int))的'input_size'参数?

这是我的 CNN 网络,由“print(model.policy)”打印: CNN政策( (演员): 演员( (features_extractor): CustomCNN( (cnn): 顺序( (0): Conv2d(1, 32, kernel_size=(3, 3), st...


Python 代码仅从 csv 文件读取 1 个值 [已关闭]

Python 文件: 名称=[] 以 open("names.csv") 作为文件: 对于文件中的行: 名称、颜色 = line.rstrip().split(",") print(f"{名称}, {颜色}") CSV ...


如何使用VObject操作VCF触点?

假设我已经构建了一个名为 vobj 的 VObject(例如,通过 vobject.readComponents(vcfStr) 构建)并想向其添加一个新的键:值对: print('k=%s v=%s' % (k,v)) 尝试: stmnt1 = "vobj.ad...


看不懂np.partition

我尝试理解这个函数,但输出看起来很奇怪。 数组 = np.array([9, 2, 7, 4, 6, 3, 8, 1, 5]) print(np.partition(数组, kth=0)) 这是我由于某种原因得到的输出: [1 2 7...


在python中按可变长度格式化

我想使用 .format() 方法打印类似楼梯的图案。 我试过这个, 对于范围 (6, 0, -1) 内的 i: print("{0:>"+str(i)+"}".format("#")) 但它给了我以下错误: 值错误:...


使用unitpy得到错误的结果?

下面所有三个都打印相同的属性,但为什么最后一个语句打印 0 电子伏特? 导入 scipy from unitpy import U、Q、单位、数量 ... def print_properties(q): print(q.unit) ...


是否可以添加解雇处理程序

我试图在弹出提示被关闭时运行一些代码,但我还没有找到方法。 我尝试了 popoverTip(tip).onDisappear { print(“tip Dismissed”) } 但这不起作用。 可以吗?


如何将 DMS 转换为给定格式的弧度:Python 中的 DD-MM-SS [已关闭]

我想知道如何将 DMS 从给定格式 DD-MM-SS 转换为弧度 这个“print (DMStoRAD(47-39-28))”的解应该是 0.831785 谢谢!


sed 分隔符(定界符)替换不适用于 p 命令

我尝试在 sed print 命令中用 # 分隔符替换 / 但没有成功。请看下面第三行: u@debian:~$ 回声 A | sed -n '/A/p' A u@debian:~$ 回声 A | sed -n '#A#p' u@debian:~$


在Shell脚本中获取进程的PID

我正在编写一个shell脚本,我想获取一个名为“ABCD”的进程的PID。我所做的是: process_id=`/bin/ps -fu $USER|grep "ABCD"|awk '{print $2}'` 这获取了两个进程的PID...


按钮和表单问题

我需要创建一个功能来创建自定义临时语音通道和文本通道,用户可以在其中设置他的私人房间。 @client.event 异步 def on_ready(): print('机器人在线') 等待


使用 PyROOT 循环绘制多个文件夹的直方图

我想问如何解决我在lxplus(ssh服务器)上的pyROOT代码中的这个错误: 这是两个代码部分: def mkdir_p(路径): #print“制作目录:”,路径 尝试: os.mak...


字符串格式化函数中的AttributeError

我在使用以下代码片段时遇到了 AttributeError 。对于这个问题的任何帮助,我将不胜感激。 def 歌词(动物、声音): print('''老麦克唐纳有一个农场,哎呀,...



我的代码出现类型错误,其中显示 your_value1 = ((20)/miles_gallon)*dollars_gallon 。我不知道如何解决类型错误

miles_gallon = 输入() 美元_加仑 = 输入() your_value1 = ((20)/miles_gallon)*dollars_gallon 你的价值2 = 75 你的价值3 = 100 print(f'({your_value1:.2f} {your_value2:.2f} {your_value3:.2f})...


Pylance 无法识别内置的 python 函数

我的猫跑过我的键盘,现在 Pylance 无法识别 print、hex、len 和 input 等内置函数,并且它标记为未定义。同样在我的 Django 项目中,一些类的导入开始了......


我想了解Python中这段代码的逻辑

我的老师给了我这个问题:制作一个读取整数并打印它的程序。 所以我找到了这段代码: integer_number = int(input("请输入一个整数:")) print("您输入了:&quo...


使用已定义类型而不是类型文字的递归类型约束?

在 Go2 泛型中,从当前草案开始,我可以使用接口指定泛型类型的类型约束。 导入“fmt” 类型 Stringer 接口 { String() 字符串 } func Print[T Str...


我尝试在cmd中执行Java程序,但使用“java”运行程序时出现错误

我可以在VS code中成功运行程序: 在 VS Code 中运行 命令: /usr/bin/env /usr/lib/jvm/java-17-openjdk-amd64/bin/java -XX:+ShowCodeDetailsInExceptionMessages -cp /home/bignosecss/.vscode-...


意外的打印输出会干扰 PyTorch 训练运行中的 tqdm 进度条

我试图了解使用 tqdm 的进度条是如何工作的。我有一些代码如下所示: 进口火炬 导入火炬视觉 print(f"火炬版本:{火炬.__version__}")


训练过程中将Transformers中trainer.py的compute_loss中标签的值打印到终端的方法

我想通过在变压器中的trainer.py的计算损失中添加代码来将标签打印到终端。 我尝试添加 print 和 logger.info,但都不起作用。 def 计算损失(se...


如何为 VertexAi java 聊天语言模型配置凭证

我正在尝试创建 VertexAi Java 聊天语言模型对象来为 Java 应用程序生成聊天响应 VertexAiChatModel 类接受以下参数 ChatLanguageModel chatMod...


限制 Java 接口的适用性

是否有可能限制Java接口的适用性?换句话说,如果我有一个类 A 和一个 Java 接口 I:是否可以强制执行,I 的实例也是 A 的实例...


driver.startActivity()函数有替代方法吗?

我正在使用Appium 2.2.3、Java JDK 17.05、Appium Java Client 9.0.0、TestNG 7.8.0。我正在尝试运行下面的代码并收到 java 空指针异常。试图寻找替代方案 活动...


2022年Flink可以支持什么Java版本?

假设我开始一个新的Flink Java项目,如果我寻找“稳定的Flink Java生产体验”,我应该使用哪个版本?官方文档说可以支持...


Spring Boot 版本与 Java 11 兼容

大家好,目前我正计划将具有 spring 版本 4.0.6 和 java 8 的独立 spring 应用程序迁移到具有 java 11 的 Spring boot 应用程序。所以,继续使用 spring boot


EclipseLink 和 Derby 与 Java 19

该项目曾经在 Java 8 和 NetBeans 8 中运行,但在将我的项目升级为使用 Java 19 和 NetBeans 16 后,我现在看到此错误: 线程“AWT-EventQueue-0”本地异常中的异常...


未预安装 Azure 管道 Java 11 工具安装程序

我正在将以下 yaml 用于 Azure 管道,但出现错误。 即使该映像已安装 Java 11。 知道我做错了什么吗? 错误: ##[错误]Java 11 未预安装...


Maven:在编译中排除 java 文件

我有一个java源文件夹,我希望将其从编译中排除。 我的文件夹位于 qa/apitests/src/main/java/api/test/omi 下。 我在 qa/bamtests 下的 pom.xml 中添加了以下条目...


如何在java中获取给定月份的最小和最大日期

如何使用 java.util.Calendar 在 java 中获取给定月份的最小和最大日期。


通过命令行(Windows)执行Java程序与Eclipse

我有一个java程序,位于/workspace文件夹中。在 /workspace 文件夹下,我有一个 /src/appFolder,其中包含 15 个 .java 文件和 /lib,其中包含 19 个 .jar 文件,我包括...


如何使用 Java 17、Spring 6、Jakarta Server Faces 4.x 和 PrimeFaces 12 检索 FacesContext?

我正在尝试将我的 JSF + PrimeFaces (UI) + Spring 应用程序从 Java 8 迁移到 Java 17,同时还将 Spring 版本迁移到 6。 为此,需要从 javax 库移出...


使用 Java SDK 查询 Kusto 时如何避免“PKIX 路径构建失败”错误?

我正在使用 Java SDK for Kusto(Azure 数据资源管理器)。 com.microsoft.azure.kusto kusto 数据 5.0.3 我是


使用 kotlin/compose 与 java/xml 指南相比

我猜我应该说我对 kotlin 的 compose 很陌生,我只用过 java/xml 的项目,我在这里很困惑。 使用java,我们为每个屏幕提供具有自己的逻辑/设计的片段。这里...


无法识别的虚拟机选项“AggressiveOpts”

我正在尝试使用 Java 8 在 intelliJ 中运行我的加特林项目。 我知道 VM 选项“AggressiveOpts”在 Java 11 中已被弃用,并在 Java 12 中被删除,但我想知道为什么我会得到这个......


如何在 Docker 容器中从 Java 执行命令?

我正在尝试在正在运行的 Docker 容器中从 Java 执行 chmod 命令: String cmd = "docker exec -it " + POSTGRES_CONTAINER_NAME + " bash -c 'chmod +x /tmp/dump.sh'";


如何使用特定的maven版本来构建我的项目?

在我的maven项目中依赖于java 8,我希望maven在构建项目时假设相同。但目前我安装的maven正在使用java 21。我如何让它使用java 8进行构建...


Java XML解析:文档(DeferredDocumentImpl)与文档(XMLDocument)在不同环境下的差异

我在 Java 8 中遇到 XML 解析问题,其中相同的代码在生产环境中的行为与较低环境中的行为不同。 这是打印 XML nodeValue 的 Java 代码片段...


Java 类在加载到内存之前会加密,在调试或反编译时无法解密

我有一个java类文件,我不想让别人看到源代码。 并且该类需要通过java代码中的类加载器来统治JVM,如下所示: 类 classLoader = Class.forName("


© www.soinside.com 2019 - 2024. All rights reserved.