我正在 Raspberry Pi 上開發 Ubuntu 20.04
我讀到這個錯誤是由 Windows 引起的 - Unix 格式沖突但是我的腳本中沒有 /r/n,我該如何解決這個問題?
#!/usr/bin/env python
import rospy
from laser_assembler.srv import *
from sensor_msgs.msg import PointCloud2
rospy.init_node("test_client")
rospy.wait_for_service("assemble_scans2")
assemble_scans = rospy.ServiceProxy('assemble_scans2',AssembleScans2)
pub = rospy.Publisher("/pointcloud", PointCloud2, queue_size = 1)
r = rospy.Rate(1)
while not rospy.is_shutdown():
try:
resp = assemble_scans(rospy.Time(0,0), rospy.get_rostime())
print "Got cloud with %u points" % len(resp.cloud.data)
pub.publish(resp.cloud)
except rospy.ServiceException, e:
print "Service call failed: %s" %e
r.sleep()
uj5u.com熱心網友回復:
Windows 默認使用 CRLF 行尾,而 Linux/Unix 使用 LF 行尾。如果您的應用程式同時使用 windows 和 linux,最好將代碼保留在 LF 中,因為這兩個平臺都理解 LF 行尾。
將代碼轉換為與 unix 兼容的行尾的一種萬無一失的方法是使用 Vi/Vim 并將行尾顯式設定為 LF。
在 Vi -:set ff=unix中使用此命令將行尾設定為 LF。然后您的代碼應該可以作業。
并且為了避免進一步的沖突,在 Windows 上開發時,請確保檢查您的文本編輯器行尾設定是否設定為 LF。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/430821.html
