Discuss / Python / 我在Mac下用IDE写了文本,保存为.py的格式,但是无法打开,求教。

我在Mac下用IDE写了文本,保存为.py的格式,但是无法打开,求教。

Topic source

danceaha

#1 Created at ... [Delete] [Delete and Lock User]

在Mac的终端进入python以后,输入文件路径/Users/用户名/FirstCode.py,但是显示SyntaxError: invalid syntax。 使用的是前俩节所说的python3.5版本,编辑文本用的IDE。

一度理解

#2 Created at ... [Delete] [Delete and Lock User]

我也是,Mac系统下不知道终端中打开*.py的路径是什么

#!/usr/bin/env python3
L = []
n = 1
while n <= 99:
    L.append(n)
    n = n + 2
print(L)
在此插入代码
在Mac下,进terminal,默认路径一般是/Users/yonghuming,cd /Desktop进入桌面,然后可以touch test.py,再open test.py,再写代码就可以了,然后chmod a+x test.py,就可以./test.py来运行程序了,或者python3.5 test.py也行

Jason_seesea

#5 Created at ... [Delete] [Delete and Lock User]

mac下还是不能在终端找到之前保存的.py文件,也不知道怎么cd

HeyYosemite

#6 Created at ... [Delete] [Delete and Lock User]

henhao


  • 1

Reply