摘要:
#!/usr/bin/python3 # This is client.py file import socket # create a socket object s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # get local machine name host = socket.gethost...
阅读全文
posted @ 2019-01-09 18:47
anobscureretreat
阅读(161)
推荐(0)
摘要:
建立文件夹hello_rospy,再在该目录下建立子目录src,cd到该src目录,运行如下命令创建工作包 pkg代表所属包名,name是文件名,type是脚本文件名称,output指定输出到屏幕 cd到src上层目录,编译并且source 编写订阅者程序 在scripts目录下新建talker.p
阅读全文
posted @ 2019-01-09 18:09
anobscureretreat
阅读(1568)
推荐(0)
摘要:
在开发中我们经常会遇到使用python代码启动launch文件这样的问题。一般的做法是使用subprocess调用roslaunch。但是这种方法使用起来并不方便。要涉及到自己去控制进程的状态。由于roslaunch实际上是用python实现的。使用python调用launch文件实际上有更简单的方
阅读全文
posted @ 2019-01-09 15:26
anobscureretreat
阅读(3358)
推荐(0)
摘要:
或 初始化节点关闭 reason 为关闭理由,字符串内容。 例子:
阅读全文
posted @ 2019-01-09 14:35
anobscureretreat
阅读(4067)
推荐(0)
摘要:
作用: 针对的log目录是家目录的.ros文件夹,目录结构是/home/xxx/.ros/log/latest .ros中除了log文件夹,其他缓存文件全部清除 然后就是log文件夹里面,这里面就是真正的log文件了,会有很多文件夹,每次重启,都会在log目录生成日志文件夹如:swswdedefra
阅读全文
posted @ 2019-01-09 00:32
anobscureretreat
阅读(1107)
推荐(0)
摘要:
#!/usr/bin/env python import rospy import tf from tf.transformations import * from std_msgs.msg import String from geometry_msgs.msg import Pose from geometry_msgs.msg import Quaternion def get_p...
阅读全文
posted @ 2019-01-08 23:58
anobscureretreat
阅读(1973)
推荐(0)
摘要:
#!/usr/bin/env python import rospy import math from tf import transformations from geometry_msgs.msg import PoseWithCovarianceStamped class PoseSetter(rospy.SubscribeListener): def __init__(sel...
阅读全文
posted @ 2019-01-08 23:56
anobscureretreat
阅读(994)
推荐(0)
posted @ 2019-01-08 09:35
anobscureretreat
阅读(176)
推荐(0)
摘要:
unix 只用\n作为行结束符,而在 dos中是以\r和\n作为行结束符, 如果一个文件是在unix系统下创建,然后想在dos下使用,就要用unix2dos,如 如果一个文件是在dos下创建的,然后想在unix下使用,就要用dos2unix,如
阅读全文
posted @ 2019-01-08 00:21
anobscureretreat
阅读(150)
推荐(0)
摘要:
http://docs.ros.org/api/geometry_msgs/html/msg/Pose.html
阅读全文
posted @ 2019-01-08 00:00
anobscureretreat
阅读(285)
推荐(0)
摘要:
sudo apt-get install libbullet-dev
阅读全文
posted @ 2019-01-07 17:57
anobscureretreat
阅读(689)
推荐(0)
摘要:
import tarfile import os def make_targz(output_filename, source_dir): print("doing!") with tarfile.open(output_filename, "w:gz") as tar: tar.add(source_dir, arcname=os.path.basename...
阅读全文
posted @ 2019-01-07 14:43
anobscureretreat
阅读(508)
推荐(0)
摘要:
import sys,os def split(fromfile,todir,chunksize): partnum = 0 inputfile = open(fromfile,'rb')#open the fromfile while True: chunk = inputfile.read(chunksize) if n...
阅读全文
posted @ 2019-01-07 14:12
anobscureretreat
阅读(531)
推荐(0)
摘要:
>>>'{:,}'.format(1234567890) >>>'1,234,567,890'
阅读全文
posted @ 2019-01-07 13:06
anobscureretreat
阅读(5370)
推荐(0)
摘要:
通过对象属性 通过下标 格式限定符 它有着丰富的的“格式限定符”(语法是{}中带:号),比如: 填充与对齐填充常跟对齐一起使用^、<、>分别是居中、左对齐、右对齐,后面带宽度:号后面带填充的字符,只能是一个字符,不指定的话默认是用空格填充比如 精度与类型f精度常跟类型f一起使用 其中.2表示长度为2
阅读全文
posted @ 2019-01-07 13:05
anobscureretreat
阅读(421)
推荐(0)
摘要:
1. 2. 输出 3. 输出 4.数字格式化 ^, <, > 分别是居中、左对齐、右对齐,后面带宽度, : 号后面带填充的字符,只能是一个字符,不指定则默认是用空格填充。 + 表示在正数前显示 +,负数前显示 -; (空格)表示在正数前加空格 b、d、o、x 分别是二进制、十进制、八进制、十六进制。
阅读全文
posted @ 2019-01-07 12:20
anobscureretreat
阅读(236)
推荐(0)
摘要:
>>> print ("{} 对应的位置是 {{0}}".format("runoob")) runoob 对应的位置是 {0}
阅读全文
posted @ 2019-01-07 12:13
anobscureretreat
阅读(1560)
推荐(0)
摘要:
整数的输出 %o —— oct 八进制%d —— dec 十进制%x —— hex 十六进制 浮点数输出 (1)格式化输出 2)内置round() round(number[, ndigits])参数:number - 这是一个数字表达式。ndigits - 表示从小数点到最后四舍五入的位数。默认值
阅读全文
posted @ 2019-01-07 12:09
anobscureretreat
阅读(309)
推荐(0)
摘要:
大神一看题目就知道用python中的string.split('\'),记得之前处理大量的文件的时候,有时候有几十万的文本文件,经常会读取获取名称,并且保存为名字一样的另外一种格式的文件 其实python中有一句话可以解决这个问题的方法,如下 根据全路径获取文件名称的方法os.path.basena
阅读全文
posted @ 2019-01-07 11:21
anobscureretreat
阅读(1639)
推荐(0)
摘要:
在平常的生活中,我们会遇到下面这样的情况: 你下载了一个比较大型的游戏(假设有10G),现在想跟你的同学一起玩,你需要把这个游戏拷贝给他。 然后现在有一个问题是文件太大(我们不考虑你有移动硬盘什么的情况),假设现在只有一个2G或4G的优盘,该怎么办呢? 有很多方法,例如winrar压缩的时候分成很多
阅读全文
posted @ 2019-01-07 10:59
anobscureretreat
阅读(1349)
推荐(0)
摘要:
当对一组数据输出的时候,我们有时需要输出以指定宽度,来使数据更清晰。这时我们可以用format来进行约束
阅读全文
posted @ 2019-01-07 10:55
anobscureretreat
阅读(9309)
推荐(0)
摘要:
os.path.join的详细解释请移步os.path模块在使用的过程中,我使用如下代码: import ospath = "F:/gts/gtsdate/"b = os.path.join(path,"/abc") 输出结果是: 'F:/abc' 并不是我期望的: "F:/gts/gtsdate/
阅读全文
posted @ 2019-01-07 10:52
anobscureretreat
阅读(220)
推荐(0)
摘要:
主要介绍了python获取文件扩展名的方法,涉及Python针对文件路径的相关操作技巧 输出结果为:.gif
阅读全文
posted @ 2019-01-07 10:45
anobscureretreat
阅读(712)
推荐(0)
摘要:
Python 异常处理 Python 异常处理 python提供了两个非常重要的功能来处理python程序在运行中出现的异常和错误。你可以使用该功能来调试python程序。 异常处理: 本站Python教程会具体介绍。 断言(Assertions):本站Python教程会具体介绍。 python标准异常 异常名称 描述 BaseException 所有异常的基类 SystemE...
阅读全文
posted @ 2019-01-07 09:48
anobscureretreat
阅读(2232)
推荐(0)
摘要:
压缩: 1. 2. 解压: 如果提示"tarfile.ReadError: not a gzip file" 将"r:gz" 改为"r" 其中open的原型是: mode的值有:
阅读全文
posted @ 2019-01-06 13:14
anobscureretreat
阅读(5855)
推荐(0)
posted @ 2019-01-04 12:40
anobscureretreat
阅读(1299)
推荐(0)
摘要:
#!/usr/bin/python # -*- coding: UTF-8 -*- import time import calendar """ 时间元组(年、月、日、时、分、秒、一周的第几日、一年的第几日、夏令时) 一周的第几日: 0-6 一年的第几日: 1-366 夏令时: -1, 0, 1 """ """ pyt...
阅读全文
posted @ 2019-01-04 11:29
anobscureretreat
阅读(195)
推荐(0)
摘要:
>>> print(time.strptime('2018-9-30 11:32:23', '%Y-%m-%d %H:%M:%S')) time.struct_time(tm_year=2018, tm_mon=9, tm_mday=30, tm_hour=11, tm_min=32, tm_sec=23, tm_wday=6, tm_yday=273, tm_isdst=-1)
阅读全文
posted @ 2019-01-04 11:26
anobscureretreat
阅读(686)
推荐(0)
摘要:
>>> time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) '2019-01-04 11:20:25'
阅读全文
posted @ 2019-01-04 11:23
anobscureretreat
阅读(256)
推荐(0)
摘要:
>>> import time >>> time.asctime() 'Fri Jan 4 11:17:20 2019' >>> time.asctime((2018, 9, 30, 9, 44, 31, 6, 273, 0)) 'Sun Sep 30 09:44:31 2018' >>> time.asctime(time.localtime(1538271871.226226)) 'S...
阅读全文
posted @ 2019-01-04 11:19
anobscureretreat
阅读(399)
推荐(0)
posted @ 2019-01-04 11:17
anobscureretreat
阅读(324)
推荐(0)
posted @ 2019-01-04 11:06
anobscureretreat
阅读(12736)
推荐(0)
摘要:
#!/usr/bin/python # -*- coding: UTF-8 -*- import time localtime = time.asctime( time.localtime(time.time()) ) print("本地时间为 :", localtime) 输出: 本地时间为 : Thu Apr 7 10:05:21 2016
阅读全文
posted @ 2019-01-04 10:51
anobscureretreat
阅读(212)
推荐(0)
摘要:
#!/usr/bin/python # -*- coding: UTF-8 -*- import time localtime = time.localtime(time.time()) print("本地时间为 :", localtime) 输出: 本地时间为 : time.struct_time(tm_year=2016, tm_mon=4, tm_mday=7, tm_hour=...
阅读全文
posted @ 2019-01-04 10:48
anobscureretreat
阅读(707)
推荐(0)
摘要:
#!/usr/bin/python # -*- coding: UTF-8 -*- import time; # 引入time模块 ticks = time.time() print("当前时间戳为:", ticks) 输出: 当前时间戳为: 1459994552.51
阅读全文
posted @ 2019-01-04 10:42
anobscureretreat
阅读(625)
推荐(0)
posted @ 2019-01-03 20:20
anobscureretreat
阅读(638)
推荐(0)
摘要:
rc.local脚本 rc.local脚本是一个ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令。该脚本位于/etc/路径下,需要root权限才能修改。 该脚本具体格式如下: #!/bin/sh -e # # rc.local # # This script is execute
阅读全文
posted @ 2019-01-03 20:05
anobscureretreat
阅读(474)
推荐(0)
摘要:
data=[0,9,3,2,1,3,2,-2,-1] result=[x for x in data if x >=0 ]
阅读全文
posted @ 2019-01-03 19:46
anobscureretreat
阅读(192)
推荐(0)
摘要:
举例说明: 要将目录logs打包压缩并分割成多个100M的文件,可以用下面的命令: tar cjf - logs/ |split -b 100m - logs.tar.bz2. 完成后会产生下列文件: logs.tar.bz2.aa, logs.tar.bz2.ab, logs.tar.bz2.ac 要解压的时候只要执行下面的命令就可以了: cat logs.tar.bz2.a* | tar...
阅读全文
posted @ 2019-01-02 16:49
anobscureretreat
阅读(487)
推荐(0)
摘要:
如:hello world文件 第一种方式 第二种方式
阅读全文
posted @ 2019-01-02 16:30
anobscureretreat
阅读(456)
推荐(0)