我的机器上有 python2.7、python3.7、python3.6。我仍然不确定如何管理和查看所有三个 python 版本的位置。
目前,我只需输入带有版本名称的 python 即可打开该终端或运行脚本。
我默认使用 python3.6 在~/.bashrc.
我已经使用 python3.6 安装了 virtualenv,因此每当我默认创建 venc 时,它都会使用 python3.6。
要使用 python2.7 创建 venv 我尝试过 -
virtualenv -p /usr/bin/python2.7 /Users/karim/Documents/venv2.7
但在这个 venv2.7 中,当我看到它给出的 python 版本时3.6。当我在终端中输入 python2.7 时,它会打开 python2.7。
我可以在虚拟环境中为 python2.7 做别名,但我怀疑这也可能在 venv 之外创建 python2.7 默认值。
我确实检查了所有 SO 线程,但没有文章帮助我在默认为 python3.6 的系统中使用 python2.7 创建 venv。
我有从车上拍摄的视频。我的程序是测量前轮和道路白线之间的距离。该脚本对于左侧视频和右侧视频运行良好。
但有时它测量的前轮和右侧白线之间的距离是错误的。
thresh = 150
distance_of_wood_plank = 80
pixel_of_wood_plank = 150
origin_width = 0
origin_height = 0
wheel_x = 0; wheel_y = 0 #xpoint and ypoint of wheel
df = pandas.DataFrame(columns=["Frame_No", "Distance", "TimeStrap"])
cap = cv2.VideoCapture(args.video)
frame_count = 0;
while(cap.isOpened()): #Reading input video by VideoCapture of Opencv
try:
frame_count += 1
ret, source = cap.read() # get frame from video
origin_height, origin_width, channels = source.shape
timestamps = [cap.get(cv2.CAP_PROP_POS_MSEC)]
milisecond = int(timestamps[0]) / 1000
current_time = str(datetime.timedelta(seconds = milisecond))
cv2.waitKey(1)
grayImage …Run Code Online (Sandbox Code Playgroud) 我的列表多次包含相同的词典,例如
喜欢
[ {'name': 'ZYLOG SYSTEMS LTD', 'gram': '1'}, {'name': 'ZYLOG SYSTEMS LTD', 'gram': '1'}]
Run Code Online (Sandbox Code Playgroud)
当我对其应用集合操作以使其与众不同时,它给出
TypeError: unhashable type: 'dict'
Run Code Online (Sandbox Code Playgroud)
使此类列表项与众不同的正确方法是什么?
我有一个文件夹,其中为每个日期创建 json 文件,并为每个小时创建日期。
我可以通过以下方式读取所有文件名:
for root, dirs, files in os.walk(rootdir):
for name in files:
if name.endswith((".json")):
print name
Run Code Online (Sandbox Code Playgroud)
根路径是/home/ubuntu/Desktop/temp/06-56-10/27
在此路径中每个小时都有子文件夹。该子文件夹包含 json 文件。在这里,name打印所有 json 文件名。但它没有给出文件的完整路径,所以我无法读取它。
感谢任何帮助
我正在阅读这样的 xlsx 文件
df = pd.read_excel('cleaned_data.xlsx', header=0)
df = df.drop(df.columns[0], axis=1)
df.head()
Run Code Online (Sandbox Code Playgroud)
问题是列名称作为第一行数据。
# reading data from csv file
df = pd.read_excel('cleaned_data.xlsx', header=0)
#df = df.drop(df.columns[0], axis=1)
df = df.drop(0, inplace=True)
df.head()
Run Code Online (Sandbox Code Playgroud)
我尝试了这种方法,但仍然不走运。有什么建议吗?
python ×5
dictionary ×1
excel ×1
list ×1
opencv ×1
pandas ×1
python-2.7 ×1
python-3.x ×1
set ×1
ubuntu ×1
virtualenv ×1