我正在编写一个go程序来将hex转换为int,binary和ascii.int和二进制文件工作正常,但ascii导致问题.如果输入文本短于2个字符,则它可以正常工作,但任何更长的文本都会导致出现格式错误的文本.我的代码如下:
package main
import "fmt"
import "strconv"
func main() {
// get input as string
fmt.Print("Enter hex to convert: ")
var input_hex string = ""
fmt.Scanln(&input_hex)
// convert hex to int and print outputs
if i, err := strconv.ParseInt(input_hex, 16, 0); err != nil {
fmt.Println(err)
} else {
// int
fmt.Print("Integer = ")
fmt.Println(i)
// ascii
fmt.Print("Ascii = ")
fmt.Printf("%c", i)
fmt.Println("")
// bin
fmt.Print("Binary = ")
fmt.Printf("%b", i)
fmt.Println("\n")
}
}
Run Code Online (Sandbox Code Playgroud)
输入hex'73616d706c65 ' 时输出的一些示例:
Enter hex to …
Run Code Online (Sandbox Code Playgroud) 我正在尝试启动依赖于QtWebKit的应用程序,但我无法导入该模块.我已经尝试通过启动python并导入其他模块进行调试.他们都工作正常(例如从PyQt4导入QtGui,QtCore)工作没有任何问题,但当我运行
from PyQt4 import QtGui, QtCore, QtWebKit
Run Code Online (Sandbox Code Playgroud)
我收到以下内容:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name QtWebKit
Run Code Online (Sandbox Code Playgroud)
我也试过以下无济于事(他们安装得很好,但不解决问题):
apt-get install --reinstall python-qt4
apt-get install --reinstall python-2.7
Run Code Online (Sandbox Code Playgroud)