小编mk4*_*444的帖子

Go Lang - 将Hex转换为ASCII

我正在编写一个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)

hex ascii go

5
推荐指数
1
解决办法
8551
查看次数

Python 2.7.11 - ImportError:无法导入名称QtWebKit - Kali Linux/Debian 8

我正在尝试启动依赖于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)

python linux debian qtwebkit

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

ascii ×1

debian ×1

go ×1

hex ×1

linux ×1

python ×1

qtwebkit ×1