在嵌入式linux上,想最简单方便的使用网络资源,如ftp,http,和socket,用c实现容易吗?
邮箱是工作中非常重要的一个工具,平常我都是使用foxmail软件或者直接登录web来操作邮件,现在我要换种方式使用邮箱.使用邮箱都是通过pop协议收取邮件,使用smtp协议发送邮件,现在我就直接在命令行中来操作一下邮箱.
要能够使用import tab,最主要的是要有readline模块。默认python2.6虽然没有装tab模块,但是装了readline模块的。如下:
软件包的下载地址:https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
–enable-R-shlib 表示生成libR.so库,当需要进行gcc等编译的时候很重要,确保之后安装R-studio-server时会出现 找不到"lib.so"文件的错误。
在linux中使用一些软件的命令行时,有时会遇到输入不正常的情况:方向键用不了,直接按方向键会出现一堆字符,退格也是,要按住ctrl才能正常退格,home和end键也不能正常用,等等。
把上面代码保存为tab.py放置在当前系统全局环境变量下,可以使用print(sys.path)查看,如:/usr/lib64/python2.6/site-packages
在windows下安装的python是带tab键自动补齐的而Linux自带的python版本过久,从新安装后没有tab键补齐功能,而且在交互模式下不小心打错了很麻烦。
周五下午在公司的服务网格月度讨论会上,一位同事为大家分享了在服务网格中使用 ebpf 来优化提升 istio 中 sidecar 和 RS 间的通信效率。听过之后手痒难,想测试一把 ebpf。当这位同事在这方面做的还是比较深入的,而且给内核和 istio 中提交了pr。有兴趣的同学可以看看他的 github:https://github.com/ChenLingPeng 还有他的 blog。
最近再弄进程管理相关的工作,因此必要的就涉及到各种系统下关于进程的管理。 这里简单的介绍下: 如何在Java中执行命令 在windows下肯定是dos命令了,而在linux则为shell命令。执行的方式差不多相同: 方法1:Runtime windows版本: Process process = Runtime.getRuntime().exec("ipconfig /all"); Linux版本: Process process = Runtime.getRuntime().exec("ifcon
上一章节我们介绍了lua的前世今生,虽然看的小伙伴并不是很多,同时也并没有上推荐没有流量;大部分觉得没什么营养,其实我个人并不这么认为:“你喜欢一门语言,是不是需要去了解这门语言的由来;作者为什么会创造这门语言?解决了哪些痛病?它自身的优势以及过往历程?”。至少通过翻译外文去了解lua语言的过往,感觉它一路挺不容易的。
周五下午在公司的服务网格月度讨论会上,一位同事为大家分享了在服务网格中使用 ebpf 来优化提升服务网格 istio 中 sidecar 和 RS 间的通信效率。听过之后手痒难,想测试一把 ebpf。这位同事在这方面做的还是比较深入的,而且给内核和 istio 中提交了pr。有兴趣的同学可以看看他的 github:https://github.com/ChenLingPeng 还有他的 blog。
工作中需要自行编译一个Python二进制程序,并尽量减少该程序依赖的库文件,使之在相同CPU架构上有更良好的可移植性。先找了下网上的资料,都不太详尽,经过探索最终还是成功了,这里记录一下过程以备忘。
在用python读取文件的时经常用到三read、readline、readlines三种方法,它们功能实质区别如下:
我们配置MySQL时,可能会注意到有一个参数叫"auto-rehash"或者"no-auto-rehash",示例可参考《GreatSQL(/MySQL)的配置文件模板样例》,他是什么意思?
对于经常使用SQLplus的网友来说,SQLplus没有提供类似DOS工具的翻页功能,故不能实现SQL语句的来回翻动。现在我们有了Uniread, 减轻了代码的反复输入的工作量,真是让人大快人心。下面是安装方法。 一、所需的安装文件(你可以Google这些文件,或给本人留言留下Email) IO-Tty-1.07.tar.gz Term-ReadLine-Gnu-1.16.tar.gz uniread-1.01.tar.gz 二、查看刚刚下载的安装文件,下面是本人的路径: [root@linux ~]# ll /robinson
./configure --prefix=/usr/local/readline/
#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e --no-check-certificate
如果觉得文章对你有帮助,点赞、收藏、关注、评论,一键四连支持,你的支持就是我创作最大的动力,技术交流可以关注公众号~
Python装完是不能用tab来补全的,我们需要将脚本放到python指定的目录下,可以使用sys.path来查看一下目录
ROOT权限是Linux内核中的最高权限,如果你的身份是ROOT,那么你就具有了ROOT权限。有了最高权限,你就可以为所欲为,换句话说,如果恶意程序获取到了ROOT权限,那么就可以肆意地破坏你的手机,获取的隐私…所以厂商一般在生产手机的时候,不会提供给用户ROOT权限,官方宣称是为了保护用户手机的安全,然后装了一堆开机自动启动,而用户这辈子也用不到也卸载不了垃圾软件(相信使用安卓的同学们都懂我的意思),而苹果所说的越狱,也就是获取ROOT权限。
那么问题来了,这些都可以解决吗?当然,我写这篇就是为了介绍如何优化SQL*Plus命令行嘛!
1.准备一个Python脚本 cat > tab.py <<EOF #!/usr/local/bin/python # python tab file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind('tab: complete') # history file histfile = os.path.join(os.environ['HOME'], '.pythonhistory') try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter EOF 2.查看Python默认的模块存放位置 [root@victor python2.7]# python Python 2.7.6 (default, Sep 17 2017, 04:41:33) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages'] 3.拷贝到目录下 cp tab.py /usr/local/lib/python2.7 4.现在可以用了 [root@victor python]# cp tab.py /usr/local/lib/python2.7 [root@victor python]# python Python 2.7.6 (default, Sep 17 2017, 04:41:33) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tab >>> import sys >>> sys. sys.__class__( sys.__sizeof__( sys.displayhook( sys.getprofile( sys.ps1 sys.__delattr__( sys.__stderr__ sys.dont_write_bytecode sys.getrecursionlimit( sys.ps2 sys.__dict__ sys.__stdin__ sys.exc_clear( sys.getrefcount( sys.py3kwarning sys.__displayhook__( sys.__stdout__ sys.exc_info( sys.getsizeof( sys.setcheckinterval( sys.__doc__ sys.__str__( sys.exc_type sys.gettrace( sys.setdlopenflags( sys.__excepthook__( sys.__subclasshook__( sys.excepthook( sys.hexversion
2,机器语言--->汇编语言--->C语言--->Java ,C#,PHP,Python
打开文件使用open()函数,用读的模式打开返回的是文件对象,它是可迭代的;如果不存在就会报错IOError,标准的语法为:
一、 安装gcc软件 redhat : yum install gcc suse linux : yast ----> gcc 二、安装python3 # wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz # tar -zxf Python-3.4.4.tgz # cd Python-3.4.4 # ./configure # make # make install #测试是否成功 # python3 Python
Linux的SQL*Plus不太好用,通过安装rlwrap可以提高用户体验,这样就可以使用光标上下键来查找历史命令,使用退格键backspace了。
我们每天都使用CLI程序(例如Terminal,cmd,Powershell等)进行软件开发。你使用的每个工具本质上都是其他软件工程师的产品,我们也可以制作自己的CLI工具。
inputrc 文件是 Readline 库的配置文件,该库在用户从终端输入命令行时提供编辑功能。它的工作原理是将键盘输入翻译为特定动作。Readline 被 Bash 和大多数其他 shell,以及许多其他程序使用。
CentOS6系统自带的python版本为2.6。Python中很多模块要求python版本为2.7。本文将介绍如果安装python2.7。
经常使用 Oracle 数据库的朋友,应该对 sqlplus 这个命令行工具不会陌生。基本上每天工作都离不开它,但是这个工具有些不太好用:
Linux下原码安装 python-3.6.6 下载 # wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz 安装依赖包 # yum -y install zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel gcc 解压并进入到解压目录 # tar xvf Python-3.6.6.tgz # cd Python-3.6.6/ 修改 Modul
python默认就可以进行tab补全命令行,在交互模式下,只要自己写个小小的tab.py模块即可;实现代码如下;
一般的Linux上都有默认的Python版本,CentOS6.5默认的Python版本的2.6.6的,因为工作原因,这里需要用到Python3.6.3的版本,在这里,小编将会一步步的教大家进行再Linux下Python3的安装。
#########################linux下vim基本设置############# 在 Linux 下对 vim 进行一些配置,使之支持如下特性: 准备: 1. 配置 vim alias,使 vim 成为默认的 vi 编辑器: # echo alias vi=\'vim\' >> ~/.bashrc # source ~/.bashrc 2. 复制默认的 .vimrc 初始化文件: # cp /usr/share/vim/vim70/vimrc_example.vim ~
Ruby是Web开发和Linux管理的最佳语言。Ruby提供了以前讨论的所有语言中的许多优点:PHP,Python和Perl。
{大神请忽略} 默认情况下python命令行下是不支持命令补全功能的,用的时候总是得百度,所以索性在博客简单记录一下,方便下次使用. 一、创建tab.py脚本 1.1 创建脚本tab.py #!
对于很多大文件的增量读取,如果遍历每一行比对历史记录的输钱或者全都加载到内存通过历史记录的索引查找,是非常浪费资源的,网上有很多人的技术博客都是写的用for循环readline以及一个计数器去增量读取,这样是十分脑残的,假如文件很大,遍历一次太久。 我们需要了解获取文件句柄的基本理论,其中包含的指针操作等。 原理是这样子,linux的文件描述符的struct里有一个f_pos的这么个属性,里面存着文件当前读取位置,通过这个东东经过vfs的一系列映射就会得到硬盘存储的位置了,所以很直接,很快。 以下是利用python实战代码,核心函数tell(),seek(). 也是调用的系统调用seek tell seek()的三种模式: (1)f.seek(p,0) 移动当文件第p个字节处,绝对位置 (2)f.seek(p,1) 移动到相对于当前位置之后的p个字节 (3)f.seek(p,2) 移动到相对文章尾之后的p个字节 tell(): 返回当前文件的读取位置。 代码: #!/usr/bin/python fd=open("test.txt",'r') #获得一个句柄 for i in xrange(1,3): #读取三行数据 fd.readline() label=fd.tell() #记录读取到的位置 fd.close() #关闭文件 #再次阅读文件 fd=open("test.txt",'r') #获得一个句柄 fd.seek(label,0)# 把文件读取指针移动到之前记录的位置 fd.readline() #接着上次的位置继续向下读取 后续:今儿有一人问我如何得知这个大文件行数,以及变化,我的想法是 方法1: 可以去遍历'\n'字符。 方法2: 从一开始就用for循环fd.readline()进行计数,然后变化的部分(用上文说的seek、tell函数做)再用for循环fd.readline()进行统计增加行数。
通过引用serial模块包,来操作串口。 1、查看串口名称 在Linux和Windows中,串口的名字规则不太一样。 需要事先查看。 Linux下的查看串口命令 root@D2:~# ls -l /dev/ttyS* crw-rw---- 1 root dialout 4, 64 Dec 26 06:53 /dev/ttyS0 crw-rw---- 1 root dialout 4, 65 Dec 26 06:41 /dev/ttyS1 crw--w---- 1 root tty 4, 66 Dec
刚学习python,其实一切都很好接受,因为有过C语言的基础,感觉一切都来得那么自然,python极其精简的语法,让我真心是爱上这种语言!相信往后python一定会在我的IT生涯中大放光彩!
vi /usr/local/python2.7/lib/python2.7/tab.py
我想比较一下 C++ 和 Python 的标准输入,但实验的结果让人大吃一惊,C++ 慢了许多。下面是我的实验代码:
简单 易学 免费开源 高层语言 可移植性 解释性 面向对象 可扩展性 可嵌入性 丰富的库
计算机最重要的功能是处理数据。一个有用的计算机语言需要拥有良好的IO功能,以便让未处理的数据流入程序,让已处理的数据流出。 与其他语言相比,Java的IO功能显得复杂。在其他语言中,许多IO功能(比如读取文件),是被封装好的,可以用一两行程序实现。在Java中,程序员往往需要多个层次的装饰(decoration),才能实现文件读取。 相对的复杂性带来的好处是IO的灵活性。在Java中,程序员可以控制IO的整个流程,从而设计出最好的IO方式。我们将在下文看到更多。 IO示例 下面是我用于演示的文件file.
EpicSim是芯华章基于Icarus Verilog开发的开源Verilog仿真软件, Github地址https://github.com/x-epic/EpicSim.
[root@web1 ~]# cd /package/ [root@web1 package]# ls apache-tomcat-8.5.39.tar.gz jdk-8u131-linux-x64.tar.gz postgresql-10.5.tar.gz redis-3.2.0.tar.gz [root@web1 package]#
QFile是一个读写文本和二进制文件和资源的I/O设备。QFile可以单独使用,或者更方便地与QTextStream或QDataStream一起使用。
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
shell =false 意思是command 使用的不是linux shell指令,如果要用shell 指令如ls 要将false 变成true, 通过指定stderr=subprocess.STDOUT,将子程序的标准错误输出重定向到了标准输出,以使我们可以直接从标准输出中同时获取标准输出和标准错误的信息。 p.poll() 返回子进程的返回值,如果为None 表示 c++子进程还未结束. p.stdout.readline() 从 c++的标准输出里获取一行.
inputrc 文件的作用是告知系统应该以怎样的键盘布局处理键盘。此文件对于 readline(readline: GNU readline library,和输入紧密相关的库)或者是一些 shell (例如 bash 等)来说十分重要。
领取专属 10元无门槛券
手把手带您无忧上云