tags: python
if __name__ == '__main__':
file_path = r'D:\\test/2022-04-20 01_16_00-SrCo311.xls'
# Push file to the interface
data = MultipartEncoder(fields={
'propertyMessageXml': (os.path.basename(os.path.realpath(file_path)), open(file_path, 'rb'), 'text/xml')})
res = requests.post(url=PUSH_URL, data=data,
headers={'Content-Type': data.content_type, 'Connection': 'close'})
Print ("Push Result:", Res.Content.decode ('UTF8'))
res.close()
workbook = xlrd.open_workbook(file_path)
sheet1 = workbook.sheets()[0]
# Delete Files
os.remove(file_path)
Question: After posting the file to the remote interface, open the excel file for classification and processing, and the excel file cannot be deleted.
Reason: Requests.post is not closed.
Solution: Make the entire post processTake it into a function, And in the functionActively turn off Request.
Practice method:
#
def post_file(file_path):
data = MultipartEncoder(fields={
'propertyMessageXml': (os.path.basename(os.path.realpath(file_path)), open(file_path, 'rb'), 'text/xml')})
r = requests.post(url=PUSH_URL, data=data,
headers={'Content-Type': data.content_type, 'Connection': 'close'})
Print ("Push Result:", R.Content.decode ('UTF8'))
r.close()
if __name__ == '__main__':
file_path = r'D:\\test/2022-04-20 01_16_00-SrCo311.xls'
# Push file to the interface
post_file(file_path)
workbook = xlrd.open_workbook(file_path)
sheet1 = workbook.sheets()[0]
# Delete Files
os.remove(file_path)
When installing the python package with xgboost, the following error may occur: Because the terminal under Window is or the GBK encoding is displayed, the PIP source code is also modified. Open C: \ P...
Problem Description: Python3.7, using the library image inside PIL just wants to get the length and wide of the picture Newspaper is wrong D:\Python37-32\python.exe D:/pyFile/python_script/img_read.py...
When I recently dealt with strange problems, I made a low -level error, wasted a lot of time, and even watched the C code at the bottom of the JDK. The following test code is run by the Windows enviro...
I don't know which version begins, AS is always prompts the following errors, A simple solution: Switch toTerminal Window, direct inputgradlew -stop ,AgainbuildIt can be running normally....
Problem Description Kafka deployed in the Windows environment is hung after running for a period of time. View loglogs/server.log Discover the following errors: reason When the consumer's offset log i...
Today, the website deployed with IIS cannot be started locally. The default port of https is 443. In order to avoid the port starting with 4 on the local computer, I tried to use port 555, and the pro...
Environment: kafka_2.11-1.1.0, win7_64, java8 Phenomenon: automatically stops after 30 seconds of startup, reported [another program is using this file, the process cannot be accessed] It can be seen ...
Regarding the idea when compiling idea: Another program is using this file and the process cannot be accessed. Problem repair record First report the original text: Error:Maven Resources Compiler: Fai...
Article catalog Problem 2. Code example 3. Reason 4. Solve Problem Python Flask Logging Log Reports An error "Another program is using this file, the process cannot be accessed" 2. Code exam...
Article catalog First, error information Second, the solution First, error information FLUTTER Mixed Development Project: In the Android project, embed the flutter page, accidentally run the Flutter p...