python2:TypeError: must be string without null bytes, not str

2023-05-16

Stack Overflow
  1. Questions
  2. Developer Jobs
  3. Tags
  4. Users
 
Log In  Sign Up

Join Stack Overflow to learn, share knowledge, and build your career.

Email Sign Up OR SIGN IN WITH
 Google
 Facebook
 
up vote 7down votefavorite
 

I'm trying to run this code, to run the same command (with little changes) with every frame that I have:

traj.reset() import os #os.chdir(outname) for i, frame in enumerate(traj): frame.superpose() comando = "python hollow.py -c constraint -o hollow_%s.pdb urei%s.pdb" % (i, i) os.system(comando) pml_cmd = "pymol urei%s.pdb hollow_%s.pdb -c -d 'as cartoon, urei%s;color gray90, urei%s;center chain A;set_view (\-0.605158150,0.089404292,0.791067421,\0.795849979,0.093013920,0.598304033,\-0.020089993,0.991641700,-0.127439827,\0.000000000,0.000000000,-202.017959595,\-28.771762848,-7.683309555,10.745590210,\-568.485290527,972.520690918,-20.000000000);bg white;as sphere, hollow_%s;color cyan, hollow_%s;ray;save urei%s.png' " % (i, i, i, i, i, i, i) os.system(pml_cmd) #remove = "rm urei%s.pdb hollow_%s.pdb" % (i, i) #os.system(remove) os.chdir("../")

I run this and I get this error:


TypeError                                 Traceback (most recent call last) <ipython-input-8-53cd3e7bd107> in <module>() 7 os.system(comando) 8 pml_cmd = "pymol urei%s.pdb hollow_%s.pdb -c -d 'as cartoon, urei%s;color gray90, urei%s;center chain A;set_view (\-0.605158150,0.089404292,0.791067421,\0.795849979,0.093013920,0.598304033,\-0.020089993,0.991641700,-0.127439827,\0.000000000,0.000000000,-202.017959595,\-28.771762848,-7.683309555,10.745590210,\-568.485290527,972.520690918,-20.000000000);bg white;as sphere, hollow_%s;color cyan, hollow_%s;ray;save urei%s.png' " % (i, i, i, i, i, i, i) ----> 9 os.system(pml_cmd) 10 #remove = "rm urei%s.pdb hollow_%s.pdb" % (i, i) 11 #os.system(remove) TypeError: must be string without null bytes, not str

I searched in internet, but I can't find a good answer.

python  null  byte  os.system
share improve this question
edited Jun 20 '15 at 14:20
nymk
2,66522233
asked  Aug 16 '13 at 2:51
Javier Cáceres Delpiano
70117
 
add a comment

2 Answers

active oldest votes
up vote 3down vote

The problem is with the \ char that should either be double escaped, i.e. changed to "\\" Or alternatively add an "r" before the string decleration:

pml_cmd = r"pymol urei%s.pdb ..."

You get this particular error since somewhere along the string there is a \0 which is interpreted as a NULL char

share improve this answer
edited Feb 5 '14 at 8:25
 
 
answered  Feb 5 '14 at 8:19
nvelan
614
 
add a comment
up vote 0down vote

I was able to resolve this error by commenting out the print:

for tarfileobj in inputs: # print(tarfileobj) tarfileobj.extractall(path=t, members=None)

I could have done print(tarfileobj.split) or printed the repr or removed \0 null bytes, or if its a tarfile, just extract it.

share improve this answer
answered  Dec 17 '16 at 3:48
jmunsch
6,62233853
 
add a comment

Your Answer

 
 
 
 

Sign up or log in

 Sign up using Google
 Sign up using Facebook
 Sign up using Email and Password
 

Post as a guest

Name
Email

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged python null byte os.system or ask your own question.

asked

4 years, 5 months ago

viewed

11,725 times

active

1 year, 1 month ago

BLOG

 
Pluralsight & Stack Overflow: Helping the World’s Developers Learn New Skills
Looking for a job?
  • Mobile Software Engineer - Android/iOS
    Stonecrop Technologies, LLCPetaluma, CA
    REMOTE
    androidruby-on-rails
     
  • Head of Trading Operations - China
    Hudson River TradingShanghai, China
    pythonc++
     

Linked

system() argument 1 must be string without null bytes, not str

Related

274
Convert a string representation of a hex dump to a byte array using Java?
995
Convert bytes to a string?
284
Check if a string is null or empty in XSLT
242
TypeError: 'str' does not support the buffer interface
120
Using pickle.dump - TypeError: must be str, not bytes
316
What is the best way to convert byte array to string?
266
Converting string to byte array in C#
182
python 3.5: TypeError: a bytes-like object is required, not 'str' when writing to a file
TypeError: must be string without null bytes, not str in os.system()
TypeError:must be a string without null bytes, not str

Hot Network Questions

  •  
    Just a short riddle
  •  
    Did the fairings from the Falcon Heavy test flight get recovered?
  •  
    Falcon Heavy stages
  •  
    The BFG, instant death from anywhere?
  •  
    What can I as a teenager do about my insanely strict parents?
  •  
    Could a Falcon Heavy test flight be responsible for these observations?
  •  
    What is this set notation called?
  •  
    Would a slower speed and lower altitude reduce fatal incidents?
  •  
    How to describe an everyday routine?
  •  
    Does the GM or Players move the session?
  •  
    What caused "blackout" in Blade Runner 2049?
  •  
    Are imaginary numbers really incomparable?
  •  
    What would make a place always misty?
  •  
    Defining a new command, every time a command is called
  •  
    Was there ever any reason to wait 30 seconds to restart a c.1995 PC?
  •  
    How to talk to someone about being chronically late - not to fix it, just to get more accurate ETAs?
  •  
    My supervisor misjudges my knowledge
  •  
    Can a 3D joint distribution be reconstructed by 2D marginals?
  •  
    The Programming Language Quiz, Mark II - Cops
  •  
    Perceived verbal agreement for an online advertisment and subsequent harrasment for payment
  •  
    Is there a keyword or operator for "nor"?
  •  
    What does 'Terminal' derive from?
  •  
    Is it safe to use a hydraulic jack as a stand? If not, why?
  •  
    Redundant rear brake systems... does this exist?
 question feed
 
STACK OVERFLOW
  • Questions
  • Jobs
  • Developer Jobs Directory
  • Salary Calculator
  • Help
  • Mobile
STACK OVERFLOW
BUSINESS
  • Talent
  • Ads
  • Enterprise
COMPANY
  • About
  • Press
  • Work Here
  • Legal
  • Privacy Policy
  • Contact Us
STACK EXCHANGE
NETWORK
  • Technology
  • Life / Arts
  • Culture / Recreation
  • Science
  • Other
  • Blog  
  • Facebook  
  • Twitter  
  • LinkedIn

site design / logo © 2018 Stack Exchange Inc; user contributions licensed under cc by-sa 3.0 with attribution required.rev 2018.2.7.28849

 

转载于:https://www.cnblogs.com/feifeiyuan/p/8431296.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python2:TypeError: must be string without null bytes, not str 的相关文章

  • Javascript 中内置函数“str.replace()”的时间复杂度或 Big O 表示法是多少?

    我很困惑如果时间复杂度str replace 函数的复杂度为 O n 或 O 1 例如 var str Hello World str str replace Hello Hi console log str gt str Hi World
  • C# 中的 String 和 string 有什么区别?

    这两者之间有什么区别 我应该使用哪一个 string s Hello world String s Hello world string https learn microsoft com en us dotnet csharp langu
  • !r 在 str() 和 repr() 中做什么?

    根据Python 2 7 12 文档 https docs python org 2 tutorial inputoutput html fancier output formatting s apply str and r apply r
  • 存储对字符串的引用

    我有一个具有 3 个字符串属性的类 我想将它们存储在一个列表中 以便当我更改列表的字符串时 它们也会在类中更新 如果我使用类对象 这很容易做到 但字符串似乎表现不同 它似乎为列表创建了对象的副本 而不是拥有指向该对象的指针 如果是 C 我该
  • 将字符串元组转换为元组

    我有一个具有以下格式的输入文件 1 1 2 1 add 11 1 2 1 3 div 2 3 1 4 1 3 2 4 2 times 240 2 2 2 3 minus 3 每一行都是我要创建的一个元组 如何将每个字符串行转换为元组 例如
  • 无法从字符串中删除“\r\n”

    我有一个像这样的字符串 la lala 135 1039 921 r n 而且我无法删除 r n 最初这个字符串是一个字节对象 但后来我将它转换为字符串 我尝试过 strip r n 与 replace r n 但什么也没有 gt gt g
  • MySQL C++ 连接器使用 SELECT 查询获取字符串

    我是 C 上的 mysql 新手 之前在 PAWN 上做过 效果很好 但现在我遇到了问题 我正在尝试从 mysql 数据库获取密码 稍后再执行其余代码 然后我会得到十六进制代码 如果是的话 这是我得到的示例 0x59fcb0 当我重新启动程
  • 将 uint64_t 转换为 std::string

    如何将 uint64 t 值传输到 std string 我需要构造包含该值的 std string 例如这样的事情 void genString uint64 t val std string str some code for str
  • 删除一个单词及其后面的所有内容

    假设我有一个字符串 C Program Files x86 Steam steam exe lets go 342131 some random text 我想从该字符串中删除 steam exe 以及之后的所有内容 所以我修剪过的字符串看
  • 如何在 Ruby 中获取从位置 N 到最后一个字符的子字符串?

    我想从字符串中获取从位置 N 到字符串末尾的子字符串 在 Ruby 中如何做到这一点 只需将字符串切片即可 string N 1
  • 在 C++ 中使用哪些字符串类?

    我们有一个用 C MFC 编写的多线程桌面应用程序 目前开发人员使用 CString 或 std string 可能取决于他们的心情 所以我们想选择一个实现 可能不是这两个 MFC 的 CString 基于写时复制 COW 习惯用法 有些人
  • 如何重构“字符串类型”代码?

    我目前正在开发一个代码库 其中有几类变量 例如数据库路径 它们简单地表示为字符串 这些 非 类型的大多数操作都在实用程序类中定义 我创建了一个新类来表示数据库 并将操作定义为实例方法 采用传统的 OOP 风格 然而 浏览大型代码库并重构它以
  • 提取两个段落之间的共同词?

    如何提取php5中两个或多个段落之间的常用词 我想总结每个文本以创建排名靠前的单词列表可能会起作用 然后比较它们 我想最基本的方法是 split each paragraph into an array of words using eit
  • 如何创建静态字符串数组?

    Note这个问题包含 Rust 1 0 之前的语法 代码无效 但概念仍然相关 如何在 Rust 中创建全局静态字符串数组 对于整数 编译如下 static ONE u8 1 static TWO u8 2 static ONETWO sta
  • 字符串变量可能尚未初始化(错误指向第 34 行)

    我一直在尝试让字符串初始化 但无济于事 我已经尝试了我遇到的所有解决方案 我不确定是因为我的无能还是因为我需要一个新的解决方案 我已经解决了程序的逻辑 所以我只需要帮助尝试初始化字符串值 如果有人可以提供帮助 我将不胜感激 P S 诅咒我想
  • 字符串等于和 == 与字符串连接[重复]

    这个问题在这里已经有答案了 我试图理解字符串连接与字符串比较的输出 需要明确的是 我有一个类使用 和 equals 来比较两个字符串 我试图将 和 equals 的输出连接到一个字符串 equals 的输出是 concats 但是 的输出是
  • 在 PHP 中用星号 (*) 提示或部分隐藏电子邮件地址

    我有这个邮件地址 email protected cdn cgi l email protection 如何将其转换为该邮件地址a email protected cdn cgi l email protection 我尝试使用strpos
  • L"" 和 u8"" 之间的区别

    以下有什么区别吗 auto s1 L 你好 auto s2 u8 你好 Are s1 and s2指的是同一类型 如果不是 有什么区别以及首选哪一个 它们不是同一类型 s2是 UTF 8 或窄字符串文字 这C 11标准草案 http www
  • sprintf 风格字符串格式化的起源

    字符串格式化概念见sprintf如今几乎可以在任何语言中找到 你知道 用 s d f 等掩盖字符串 并提供变量列表来填充它们的位置 哪种语言最初具有提供此功能的库函数或语言结构 请指定某种来源参考以确认您的主张 以便我们避免纯粹的猜测或猜测
  • 为什么不能使用 String.Empty 作为默认参数值?

    今天我在构造函数中创建默认参数值 public SomeClass String something String Empty 编译器抱怨道 something 的默认参数值必须是编译时的 持续的 我的印象是 String 类上的 Empt

随机推荐

  • 检测SqlServer服务器IO是否瓶颈

    通过性能监视器监视 Avg Disk Queue Length 小于2 Avg Disk sec Read Avg Disk sec Write 小于10ms 可以用数据收集器定时收集 平均物理读次数最多的SQL语句 xff1a selec
  • Ubuntu下提升当前用户权限到root权限的坑与出坑方法

    由于使用gedit过程中很多时候权限不足 xff0c 想到将普通用户的权限提升为root权限的用户 经过问百度 xff0c 有博客说通过修改 34 etc passwd 34 文件 xff0c 提升用户权限 如博客 xff1a https
  • MariaDB 表的基本操作(3)

    MariaDB数据库管理系统是MySQL的一个分支 主要由开源社区在维护 采用GPL授权许可MariaDB的目的是完全兼容MySQL 包括API和命令行 MySQL由于现在闭源了 而能轻松成为MySQL的代替品 在存储引擎方面 使用Xtra
  • 流程审批设计

    这是我的项目中使用的一套关于工作流和审批流的配置 xff0c 算是比较简单的 xff0c 这里只写其中比较核心的思路 xff0c 算是对之前工作的一个技术总结吧 以下是数据库设计 xff1b 后面再跟据实例分析每个表的作用 首先是流程配置表
  • 文件流写到ftp服务器,采用ftpclient.storeFile(String, Inputstream)将流写到服务器,没报错但服务器上没有文件,这是怎么回事...

    满意答案 qingjixiaolan 推荐于 2018 04 27 创建一个FtpClient对象 FTPClient ftpClient 61 new FTPClient 上传文件 读取本地文件 file xff1a 需要上传的文件地址
  • TSA not available (for R version 3.6.3) 解决方法

    安装包 全部安装包路径 xff1a https cran r project org src contrib Archive TSA下载路径 xff1a https cran r project org src contrib Archiv
  • android banner设置图片比例,Banner基本使用 2.1.0

    Step 1 依赖banner Gradle dependencies compile 39 com youth banner banner 2 1 0 39 Step 2 添加权限到你的 AndroidManifest xml Step
  • int,bool,字符串知识总结

    一 xff1a int整数类型 bool类型 一 xff1a int类型 xff0c 整数 1 xff0c bit length 返回一个数的二进制长度 a 61 5 0 1 10 11 100 101 print a bit length
  • postgresql从库搭建

    1 复制类型 PostgreSQL支持物理复制 xff08 流复制 xff09 及逻辑复制2种 通过流复制技术 xff0c 可以从实例级复制出一个与主库一模一样的实例级的从库 流复制同步方式有同步 异步两种 另一种复制方式为逻辑复制 xff
  • NotePad 快捷键

    转载于 https www cnblogs com pxzbky p 11567346 html
  • 网络通信原理和过程

    当时查http协议的时候了解的一些网络底层的知识 xff0c 感觉挺有意思的 xff0c 就把多位博主的资料整料梳理出来整理到一堆 xff0c 就当是一篇科普文吧 一 网络的五层模型 如何分层有不同的模型 xff0c 有的模型分七层 xff
  • Springboot读取本地图片并显示

    在application xml中配置url访问路径和本地图片路径 xff1a 配置 url中访问路径 xff0c 这里为 xff1a localhost 8080 image 配置 本地图片保存的路径 xff0c image会根据D up
  • vue路由跳转到指定页面

    1 this router push name 39 Home 39 2 this router push path 39 view 39 3 this router replace name 39 Home 39 4 this route
  • Post方式提交,通过上下文HttpContext,Request[""]获取

    问题场景如下 xff1a 在项目的一般处理程序中 xff0c 所有方法都是通过 context Request 34 参数名 34 ToString 来获取参数的值 如果我直接将参数追加到URL后面 xff0c 直接Post xff0c 后
  • maven项目添加mysql的链接驱动

    Maven项目中添加JDBC驱动 在pom xml配置文件中添加 lt dependency gt lt groupId gt mysql lt groupId gt lt artifactId gt mysql connector jav
  • 2.5年, 从0到阿里

    从来没有想到自己的求职之路会这么顺利 第一次投阿里就拿到了offer 以前一直都是做好被刷的准备的 3月31号晚上收到了来自阿里的正式offer 签下录取意向书 粗略算了一下 从2012年9月份正式入学进入计算机系到2015年3月签下阿里o
  • 我的2013—弃金融IT,从SAP业务

    我的2013 xff0c 是动荡的一年 xff1b 这一年 xff0c 我跳巢了 xff1b 这一年 xff0c 我换行业了 xff1b 这一年 xff0c 我离开了生活5年的长春 xff0c 来到成都 xff1b 这一年 xff0c 我放
  • [转载]LazyWriter(惰性写入器) 进程的作用

    Q What Does the LazyWriter Process Do The LazyWriter process is a periodic process that checks the status of BPool buffe
  • Python——爬取百度百科关键词1000个相关网页

    Python简单爬虫 爬取百度百科关键词1000个相关网页 标题和简介 网站爬虫由浅入深 xff1a 慢慢来 分析 xff1a 链接的URL分析 xff1a 数据格式 xff1a 爬虫基本架构模型 xff1a 本爬虫架构 xff1a 源代码
  • python2:TypeError: must be string without null bytes, not str

    Stack Overflow QuestionsDeveloper JobsTagsUsers Log In Sign Up Join Stack Overflow to learn share knowledge and build yo