首页 \ 问答 \ 如果在引用上调用,wait()是否等待引用的对象或引用本身?(Does wait() wait for the referenced object or the reference itself if called on a reference?)

如果在引用上调用,wait()是否等待引用的对象或引用本身?(Does wait() wait for the referenced object or the reference itself if called on a reference?)

在这种情况下,是否会通知线程1(在等待引用而不是对象本身时)?

static Object lock=new Object();
//Thread 1:
Object reference=lock;
reference.wait();

//Thread 2:
lock.notify();

In this case, will thread 1 actually be notified (while waiting for the reference instead of the object itself)?

static Object lock=new Object();
//Thread 1:
Object reference=lock;
reference.wait();

//Thread 2:
lock.notify();

原文:https://stackoverflow.com/questions/50499537
更新时间:2023-10-26 14:10

最满意答案

只需添加

from zipfile import ZIP_STORED

您的导入,或替换您的导入

from zipfile import *

将所有符号从zipfile导入到当前名称空间。


Just add

from zipfile import ZIP_STORED

to your imports, or replace your import with

from zipfile import *

to import all symbols from zipfile to the current namespace.

相关问答

更多
  • 正确的ZIP文件在开始时总是有“\ x50 \ x4B \ x03 \ x04”。 您可以使用以下代码测试文件是否真的是ZIP文件: with open('/path/to/file', 'rb') as MyZip: print(MyZip.read(4)) 它将打印文件的标题,以便检查。 更新奇怪,testzip()和所有其他功能工作良好。 你有没有试过这样的代码? with zipfile.GzipFile('/path/to/file') as Zip: for ZipMember in ...
  • 这是因为ZipFile需要您指定压缩方法。 如果不指定它,它将压缩方法设为zipfile.ZIP_STORED ,它只存储文件而不压缩文件。 您需要指定方法为zipfile.ZIP_DEFLATED 。 您将需要为此安装zlib模块( 通常默认情况下会安装)。 import zipfile def main(archive_list=[],zfilename='default.zip'): print zfilename zout = zipfile.ZipFile(zfilename, ...
  • 只需添加 from zipfile import ZIP_STORED 您的导入,或替换您的导入 from zipfile import * 将所有符号从zipfile导入到当前名称空间。 Just add from zipfile import ZIP_STORED to your imports, or replace your import with from zipfile import * to import all symbols from zipfile to the current ...
  • 在将压缩数据写入其中时,您应该很可能以二进制模式打开文件。 也就是说,你应该使用 zippedfile = open('%stemp/tempfile.zip' % settings.MEDIA_ROOT, 'wb+') You should very probably open the file in binary mode, when writing zipped data into it. That is, you should use zippedfile = open('%stemp/tempf ...
  • 是的,您可以从子目录中删除元素,这将确保os.walk()不会进入这些目录。 示例 - for dirname, subdirs, files in os.walk("D:\\review docs"): if 'exclude directory' in subdirs: subdirs.remove('exclude directory') zf.write(dirname) for filename in files: zf.write(os.p ...
  • 有两种方法可以解决它: 1)使用from ,并在这种情况下删除zipfile命名空间: from zipfile import * #set filename fpath = '{}_{}_{}.zip'.format(strDate, day, week) #use zipfile to get info about ftp file zip = ZipFile(fpath, mode='r') 2)使用直接import ,在这种情况下使用像你一样的完整路径: import zipfile #set ...
  • zip格式没有任何简单的方法来删除或替换存档中的文件。 可能有一些库可以就地这样做,但我不知道一个。 可是等等: zip(1)完全可以做到这一点(使用“-u”选项)所以为什么不python? 首先,所有-u都告诉它“如果时间戳不是更新的话,只替换现有文件”,这在这里并不重要。 没有-u它仍然会,默认命令是add ,它在不检查时间戳的情况下执行相同的操作: 更新现有条目并添加新文件。 如果存档不存在则创建它。 这是默认模式。 但是,更重要的是,正如您引用的联机帮助页明确指出: Zip文件。 更改现有zip存档 ...
  • 正如bruno所提到的,我认为你无法检查zipfile内容,但我认为一种更清晰的方法可以在提取后删除它们,因此你可以使用shutil.rmtree删除其他内容。 def main(): rootPath = "C:\\rootpath" destPath = "C:\\Test" allFileList = [] zipList = [] # Create a list containing all files contained within L:\Data\Cases for dirname, dirn ...
  • 2007年提交了与此问题相关的错误报告: http : //bugs.python.org/issue1760357 问题是由Windows localtime函数中的错误引起的,并且除了抛出ValueError之外,没有时间模块可以做的事情。 我解决了这个问题: try: zip.write(absfilename, zipfilename) except ValueError: os.utime(absfilename, None) zip.write(absfilename, ...
  • zipfile.open以二进制模式打开压缩文件,它不会zipfile.open回车符(即'\ r'),也没有在我的测试中使用TextIOWrapper的默认值。 尝试配置TextIOWrapper以使用通用换行符(即newline=None ): import zipfile import io zf = zipfile.ZipFile('data/test_zip.zip') for filename in zf.namelist(): with zf.open(filename, 'r') ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。