简体   繁体   English

将代码从 2.7 转换为 3.5

[英]Convert Code from 2.7 to 3.5

I'm very new to learning python, and was wondering if someone could convert a previously answered question so that it would work in Python 3.5.我对学习 Python 非常陌生,想知道是否有人可以转换以前回答的问题,以便它可以在 Python 3.5 中使用。 I would like to get the exact same info as the original question.我想获得与原始问题完全相同的信息。

Cannot get table data - HTML 无法获取表格数据 - HTML

Thanks in advance!提前致谢!

Take the code and run this on the file, assuming it is called 'my_code.py'获取代码并在文件上运行它,假设它被称为“my_code.py”

2to3 -w my_code.py

The code will now be Python 3 code!代码现在将是 Python 3 代码! This process will save the old Python 2 code as my_code.py.bak should you want to restore it.如果您想恢复旧的 Python 2 代码,此过程会将旧的 Python 2 代码保存为 my_code.py.bak。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM