oraclize result以string格式返回,solidity没有uint(string)这样的强制转换功能,如果要解析其中的数字,可以用oraclize提供的parseInt方法:
pragma solidity ^0.4.21; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; contract StringToUint is usingOraclize{ string price = "110.42"; string realStringPrice = "$10.33"; string badString = "abc"; uint public priceInt = parseInt(price,2); //11042 uint public priceIntger = parseInt(price); // 110 uint public realStringPriceInt = parseInt(realStringPrice,2); //1033 uint public realStringPriceInteger = parseInt(realStringPrice); //10 uint public badStringInt = parseInt(badString); //0 uint public badStringInteger = parseInt(badString,2); //0 }